Skip to content

The org's pull requests in one answer: GET /api/prs/overview - #988

Merged
coderhelm[bot] merged 4 commits into
pull-requests-viewfrom
prs-overview
Dec 5, 2026
Merged

coderhelm[bot] merged 4 commits into
pull-requests-viewfrom
prs-overview

Conversation

@nambok

@nambok nambok commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

GET /api/prs/overview?org=&repo=&window= answers "what is the state of our pull requests" in one read. It is the summary layer above the per-PR list, and it counts every pull request in the team's repos: people's, CoderHelm's, Dependabot's and other bots'. CoderHelm's pull requests are one slice and appear only in its own section.

It returns computed facts only:

  • Summary: a written summary (verdict, three fixed tiles, up to five ranked items, what changed, and a stability line and a CoderHelm line that always appear).
  • Strip and aging: the stage strip with week-over-week changes, 8-week lines and past-p85 counts; the whose-turn split and a condition row (stale, abandoned, zombie, drift); and the aging dots.
  • Repos: org and repo p50, p85 and p95, and one row per repo with a health word on a printed scale.
  • Panels: the stale, failures, review-health and security panels, this week's events, and CoderHelm's slice (author, fixer, reviewer, run end states, exceptions).

What isn't stored yet comes back as null and is named in missing, so nothing is faked.

Builds on #985's storage (pr_record, pr_history: history rows, snapshots, backfill progress) and imports its types.

Changes

  • common/src/pr_overview.rs: the pure builder.
    • Thresholds: percentiles of the scope's own history. A repo uses its own after 30 merges in 90 days, else the org's. Until 8 weeks of history exist and the backfill is done, the external bands stand in, labeled as external.
    • Floors: no rate is shown on fewer than 10 events. A change is mentioned only when it is 2 or more and at least 10% of the week before, and a wait only past a day.
    • Fact-only summary: the sentences are fixed templates, and every number in them goes through Builder::num, so it is a fact in facts.
    • Names: a login appears only as the owner of one "Needs attention" item.
  • gateway/src/routes/prs_overview.rs: the route, under "view".
    • It reads the team's records and joins (the same read as the list), history, the scope's and the busiest repos' snapshots, and the backfill progress, all keyed by the session's team.
    • A 60-second cache is keyed by installation, team, org, repo and window. It is listed in bm_teams_never_cross.
  • gateway/src/routes/prs.rs: GET /api/prs gains the overview's drill-down filters, stage= and past=p85|p95. Counts stay over the whole scope. read_all and items_under become pub(crate).
  • Incident case xz_org_overview_facts_only (.rs and .md). It pins five things:
    • no per-person ranking, count or duration is returned;
    • every number in the summary is a fact;
    • one team never sees another's data;
    • an org with no CoderHelm pull requests gets the whole overview;
    • the Stale tile equals the Stale panel's headline, and rates are shown only on 10 or more events.

Verification

On the head, with main and #985's head merged in:

  • cargo fmt --all --check and rustfmt --edition 2021 --check worker/src/passes/incidents/*.rs pass.
  • cargo clippy -p common -p worker -p gateway --all-targets -- -D warnings passes.
  • cargo test -p common -p worker -p gateway: 7,741 passed, 0 failed, 31 ignored. The run includes the new xz case, bm_teams_never_cross with the new cache, and the ownership phrase scan.
  • brand_spelling.py, domain_examples.py and text_guard.py (on this body and the commit messages) pass.

What's real and what isn't yet

  • Computed from Every open pull request has a record and one state, read by the merge gates and the new pull requests view #985's records, history, snapshots and backfill progress:
    • the strip, with deltas and sparklines once snapshots exist;
    • turns, needs-a-decision, and the stale, abandoned and zombie conditions;
    • the aging dots and the p50/p85/p95 lines;
    • the repos table: health, past usual, stale, first review, human-reviewed share, CI first try, reverts, large share, security past SLA from the record's category and severity, and unreviewed bypasses;
    • review coverage, first review by people against any reviewer, quick approvals by size, the queue and its gap, and concentration as a share;
    • CI fail rate, flaky checks, reverts, the "later reverted or hotfixed" proxy and hotfix suspects;
    • bypass merges, merges with no independent approval, and dependency-bot merge and superseded rates;
    • events (reverts, bypasses, SLA breaches, new flaky checks, stopped runs);
    • CoderHelm's author, fixer, reviewer and exception figures.
  • "Not enough history yet" (named in missing) until enough has been stored: week-over-week deltas and 8-week ranges, drift (10 merges), rubber-stamp by size (10 approvals), and, while the backfill runs, everything that needs history (with its progress).
  • "Not recorded yet", because nothing stores it today:
    • main's red time and PRs blocked by a red main;
    • runner queue p95;
    • CoderHelm's findings funnel and verified-fixed rate;
    • run end states (History.run_outcome is never written yet);
    • cost per merged PR;
    • single-reviewer paths;
    • the sensitive-path list;
    • security alerts with no PR.

Stacked on #985 (base pull-requests-view). The dashboard is CoderHelm/coderhelm#546.

Every pull request in the team's repositories counts, people's, CoderHelm's
and other bots'; CoderHelm's are one slice. Computed facts only, with
thresholds from the scope's own percentiles, no rate on fewer than 10
events, and what isn't stored yet named in `missing`. No per-person
ranking, count or duration; a login appears only as one item's owner.
The summary's numbers are all facts. GET /api/prs takes the overview's
drill-down (stage, past p85/p95). Incident case xz pins it.
…e numbers

The stability line says "over the last month" so every number in the summary
is a fact; the incident case reads the route's source without whitespace, so
formatting can't hide a read.
… at once (#986)

A run stopped because the change it built on closed now goes back to
waiting as soon as GitHub reports the change reopened, not at the
15-minute sweep. The pull request handler sends the team's change check
for a close or a reopen before any return a reopen reaches, naming the
change, and the worker reads the runs that change's close stopped (the
sweep stays the backstop for every team).

A recovery posted after an alert route's quiet window now closes the
run waiting on a person for that alert, through the same path a
recovery posted at once uses (common::run_wake::alert_cleared, which
the gateway's alert_delivery now calls too).

Incident case xx_waits_never_outlive_their_event.
@nambok nambok added the ch-review CoderHelm reviews this pull request label Dec 5, 2026

@coderhelm coderhelm Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved with notes fd7ac09 (merged)

lines: &lines,
merged_w: &merged_w,
merged_prev: &merged_prev,
merges_range: range8(i.snaps, now, |s| s.merges),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 FYI: Window merge count is compared with a 7-day snapshot range (correctness, not verified)

merges_range: range8(i.snaps, now, |s| s.merges) takes the 8 weekly values of Snapshot.merges, which pr_history.rs:349-351 documents as "In the 7 days to the snapshot". The summary compares that range with merged_w.len(), which covers the whole window_days (7, 14 or 28). With window=14d or 28d the count is about 2 or 4 times the weekly range. The merges_out test (about line 1685) then never fires, and the sentence reads "N merged (usual lo to hi)" with N over 14 or 28 days against a 7-day range. The verdict and the printed fact are misleading for non-default windows. merges_median and the quiet_week test (about line 1683) have the same mismatch.

FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.

.filter(|h| {
h.reverted_by
.as_ref()
.is_some_and(|(_, _, t)| *t > now - 14 * DAY)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 FYI: "Reverts this window" is capped at 14 days (correctness, not verified)

reverted_14 keeps only reverts with t > now - 14 * DAY. The summary's stability line and the Reverts tile filter it again with t > c.since and label the result "this window". For window=28d, reverts from days 15 to 28 are dropped, so the count is understated. Reverting part of the change isn't shown to fix the check: the failing test doesn't pass on the base branch's head. Build the revert list from max(window, 14d) and filter by since where the label says "window".

FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.

let quiet = ro.is_empty() && arrivals == 0 && rm.is_empty();
let past_range = range8(snaps, now, |s| s.past_p85);
let merges_range = range8(snaps, now, |s| s.merges);
let obligation = sec.iter().any(|(s, _)| *s == "critical") || bypass_unreviewed > 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 FYI: Repo health and flags mishandle kev and moderate severity (correctness, not verified)

Sla::days, the open-severity buckets and sev_rank all treat "kev" as critical and "moderate" as medium. The repo row does not. obligation checks *s == "critical" (line 872) and worst (lines 860-864) falls back to "low" for anything outside critical/high/medium. A kev fix past its 7-day SLA therefore makes the org verdict "Slipping" (sev_rank == 0) while its repo shows "healthy", or is flagged "low past SLA". A moderate fix is also labeled "low". Normalise the severity once, for example with the bucket mapping at lines 1285-1290, and use it for worst, obligation and the flags.

FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.

if past.is_some() && limit_secs.is_none() {
sources.push(json!({"name": "percentiles", "read": "held", "detail": "no percentiles yet, so every open pull request is shown"}));
}
let picked: Vec<pr_view::Row> = rows

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 FYI: past= drill-down doesn't use the percentile the overview counts with (correctness, not verified)

The overview counts "past usual" with past_p85 in pr_overview.rs (~356). That uses Lines from scope_lines, which recomputes percentiles from history: a repo's own after 30 merges, else the org's. The past= filter here (past_secs, ~675) reads the newest snapshot of q.repo or q.org and takes its pct.cycle. Three results follow. (1) A repo under 30 merges is measured against the org line by the overview but against the repo's own snapshot line here, so the drilled rows can differ from the count. (2) With neither org nor repo on the list query, past_secs returns None, and the code then returns every open PR with only a sources note. The overview always sets an org scope (it infers one from the first open PR), so its count is for one org while the drill returns all of them. (3) A scope with no snapshot in the last 3 days also shows every open PR. In each case the list under a "past p85: N" link shows a different set than N. This is the main use of the new filter.

FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.

if let Some(r) = &repo {
super::reviewer::validate_repo(r)?;
}
let days =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 FYI: Near-identical helpers added together (scope, not verified)

services/gateway/src/routes/prs_overview.rs adds day next to day_of (in services/common/src/pr_overview.rs), added in the same change. Keep one helper with the shared logic (a parameter for what differs) and call it from both places. If the ticket truly needs it, say why on a line Wider than the ticket: services/gateway/src/routes/prs_overview.rs: <why>.

FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.

@coderhelm
coderhelm Bot merged commit 053806e into pull-requests-view Dec 5, 2026
2 checks passed
@coderhelm

coderhelm Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Post-merge health check: deployed, but not from main: the deploy of 053806e completed and stayed green for the full 15-minute watch window, but main does not hold 053806e, so this is not called healthy: what went out is code main does not have.
Auto-merge

  • ✅ CoderHelm approved
  • ✅ CI green
    The rest is in the pull request description.

nambok added a commit that referenced this pull request Dec 6, 2026
… gates and the new pull requests view (#985)

* Every open pull request has a record and one state, read by the merge gates and the new pull requests view

A durable record per open pull request in the team's connected repositories,
written from the webhooks already received for every author and kept honest by
a bounded GraphQL sync under the shared GitHub budget (sweep:dashboard_prs).
One function (pr_needs::decide) decides each pull request's state, its turn and
what it needs next from whom; the run's watch stores its standing and the
reviewer's auto-merge gate merges only what it calls ready. GET /api/prs and
GET /api/prs/detail serve the dashboard's pull requests page under the "view"
capability. Incident case xw holds it.

* Format the pull requests route

* Keep each pull request's history, change log and nightly percentiles for the org overview

Every duration starts at ready for review, and human review leaves out
the author and every bot. Records keep their state and turn change log,
people's reviews and review requests, and check transitions. A merged or
closed pull request leaves a history row kept 400 days with its run and
session links and revert and follow-up links. A nightly job writes each
org's and repository's snapshot and percentiles, team-scoped and bounded.

* Every pull request, whoever wrote it: history backfill and health signals

A resumable 14-month backfill reads each organization's closed and merged
pull requests into history under the shared budget, pausing on a held
budget or rate limit and showing its progress per repository. Records
keep separate author, reviewer and bot clocks, drift against the base,
every check attempt (flaky reads as flaky), category and severity; history
adds review coverage, bypass merges, suspect follow-ups with their reason,
and CoderHelm's last run outcome and stop reason.

* The org's pull requests in one answer: GET /api/prs/overview (#988)

* The org's pull requests in one answer: GET /api/prs/overview

Every pull request in the team's repositories counts, people's, CoderHelm's
and other bots'; CoderHelm's are one slice. Computed facts only, with
thresholds from the scope's own percentiles, no rate on fewer than 10
events, and what isn't stored yet named in `missing`. No per-person
ranking, count or duration; a login appears only as one item's owner.
The summary's numbers are all facts. GET /api/prs takes the overview's
drill-down (stage, past p85/p95). Incident case xz pins it.

* Overview: clippy's shapes, and words without hand-off phrases or loose numbers

The stability line says "over the last month" so every number in the summary
is a fact; the incident case reads the route's source without whitespace, so
formatting can't hide a read.

* A reopened change and a later alert recovery reach their waiting runs at once (#986)

A run stopped because the change it built on closed now goes back to
waiting as soon as GitHub reports the change reopened, not at the
15-minute sweep. The pull request handler sends the team's change check
for a close or a reopen before any return a reopen reaches, naming the
change, and the worker reads the runs that change's close stopped (the
sweep stays the backstop for every team).

A recovery posted after an alert route's quiet window now closes the
run waiting on a person for that alert, through the same path a
recovery posted at once uses (common::run_wake::alert_cleared, which
the gateway's alert_delivery now calls too).

Incident case xx_waits_never_outlive_their_event.

* Answer the review: the gate never waits on what GitHub does not require, the sync never undoes events, history is never thinned

The repository's approval rule is GitHub's own review decision and the
team's rule is a person's approval; a review no rule requires is named,
never a hold. The sync never reopens a closed record, yields to events
newer than its read, replaces the reviews and requests it lists, and marks
lists cut by their page size. History rows merge by source, so the
backfill never thins a row written from events. The review decision is
worked out at review events and used for bypass only when fresh. Stacks
join within one repository, and the detail decides with the list's own
linked records.

* The sync writes each field only when its search was read after the last event that wrote it

A page read before an event could undo that event's queue entry, auto-merge
or review decision. Every field both events and the sync write (state,
title, draft, head, base, labels, review requests, reviews, review decision,
checks, mergeability, auto-merge, the merge queue, size) now keeps the time
an event last wrote it, and the sync writes that field only when its read
is newer. Tests cover a queue, an auto-merge and a review decision event
landing after the read and surviving the page.
coderhelm Bot pushed a commit that referenced this pull request Dec 6, 2026
Moves dashboardRef to coderhelm main (e65ef06), which adds the Pull requests
page (#544), the follow-up on main (#545) and the pull requests overview
(#546). The API they read shipped in #985 and #988.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ch-review CoderHelm reviews this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant